import request from "@/utils/request";

//上传图片时，获取oss数据
export const aliOssSecurityToken = () => {
  return request({
    url: "sass/file/getAliOssSecurityToken",
    method: "get"
  });
};

//查询商品规格list
export const getSpecificationList = props => {
  return request({
    url: "/mall/admin/specification/getSpecificationList",
    method: "post",
    data: props
  });
};

//添加、编辑商品规格
export const saveSpecification = props => {
  return request({
    url: "/mall/admin/specification/saveSpecification",
    method: "post",
    data: props
  });
};

//删除商品规格
export const deleteSpecification = props => {
  return request({
    url: "/mall/admin/specification/deleteSpecification",
    method: "delete",
    params: props
  });
};

//复制商品规格
export const copySpecification = props => {
  return request({
    url: "/mall/admin/specification/copySpecification",
    method: "post",
    data: props
  });
};

// ===================新增/编辑===========================

//图片上传，存到业务端
export const imgsUpload = props => {
  return request({
    url: "/sass/file/upload",
    method: "post",
    data: props
  });
};

// 获取商品分类tree
export const getcategoryList = props => {
  return request({
    url: "/mall/admin/category/getcategoryList?search=" + props.searchkey,
    method: "get"
  });
};
// 获取商品分类tree，过滤掉了禁用项
export const getcategoryList2 = props => {
  return request({
    url: "/mall/tenant/category/getcategoryList?search=" + props.searchkey,
    method: "get"
  });
};

//获取上架协议内容
export const getAgreementList = props => {
  return request({
    url: "/mall/agreement/getAgreementList",
    method: "get",
    params: props
  });
};

//获取数据字典
export const getEnumAll = props => {
  return request({
    url: "/dbo/system/dict/type/getAll",
    method: "get",
    params: props
  });
};
/**
 * 获取租户数据字典
 */
export const getDictList = props => {
  return request({
    // url: "/crm/system/getSassDictListSys",
    url: "/sass/dict/getSassDictListSys",
    method: "get",
    params: props
  });
};
//获取供应商列表-工厂列表
export const getProvideList = props => {
  return request({
    url: `/mall/tenant/merchant/tenant/getProvideList?current=${props.current}&size=${props.size}`,
    method: "post",
    data: { status: props.status }
  });
};
//获取自有供应商列表-工厂列表
export const getSuppliers = props => {
  return request({
    url: "/mall/tenant/merchant/product/getSuppliers",
    method: "post"
  });
};

//获取商品规格
export const getSpecList = props => {
  return request({
    url: "/mall/tenant/specification/getSpecificationList ",
    method: "post",
    data: props
  });
};

//查询商品属性list列表tree
export const getStastsList = props => {
  return request({
    url: "/mall/tentant/stasts/getStastsListByTree",
    method: "post",
    data: props
  });
};

//查询商品属性+通用属性list列表tree
export const getStastsListAll = props => {
  return request({
    url: "/mall/tenant/stasts/getStastsCommonList",
    method: "post",
    data: props
  });
};
// 省市区
export function getArea() {
  return request({
    url: "/dbo/region/tree"
  });
}

//创建-保存、发布商品
export const saveProduct = props => {
  return request({
    url: "/mall/tenant/merchant/product/user/create",
    method: "post",
    data: props
  });
};
//获取商品详情
export const getProductDetail = props => {
  return request({
    url: "/mall/tenant/merchant/product/getDetail",
    method: "post",
    data: props
  });
};
//编辑商品
export const eidtProduct = props => {
  return request({
    url: "/mall/tenant/merchant/product/save",
    method: "post",
    data: props
  });
};

//sku切换上架时，校验是否可以上架
export const checkMerchantSku = props => {
  return request({
    url: "/mall/tenant/merchant/product/checkMerchantSku",
    method: "post",
    data: props
  });
};

//查询商品富文本详情内容
export const getRichText = props => {
  return request({
    url: "/sass/rich/getRichText",
    method: "post",
    data: props
  });
};
//保存商品富文本详情内容
export const saveRichText = props => {
  return request({
    url: "/sass/rich/saveSassRichText",
    method: "post",
    data: props
  });
};
// 获取商品品牌列表
export const getBrandListApi = props => {
  return request({
    url: "/mall/common/getBrandList",
    method: "get",
    params: props
  });
};
//商品上架
export const listing = props => {
  return request({
    url: "/mall/tenant/merchant/product/listing",
    method: "post",
    data: props
  });
};
//复制商品，返回商品详情信息
export const getCopyDetail = props => {
  return request({
    url: "/mall/tenant/merchant/product/copy",
    method: "post",
    data: props
  });
};

//获取质保模板list
export const getZbTempList = props => {
  return request({
    url: "/mall/tenant/factory/warranty/template/AllList ",
    method: "post",
    data: props
  });
};

export const getSpecificationTreeList = data => {
  return request({
    url: "/mall/tenant/specification/getSpecificationList",
    method: "post",
    data
  });
};
export const getSellingPrice = data => {
  return request({
    url: "/mall/tenant/merchant/pricing/selling-price",
    method: "post",
    data
  });
};

// 是否存在特殊定价
export const getSpecial = props => {
  return request({
    url: `/mall/tenant/merchant/pricing/${props.categoryId}/special`,
    method: "get",
    params: props
  });
};

/**
 * 2.定制模板列表(下拉)
 */
export const getCustomList = data => {
  return request({
    url: "/mall/tenant/customization/template/list",
    method: "post",
    data
  });
};
